package com.example.studentmanagement.view;

import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.example.studentmanagement.R;

public class Top_Bar extends RelativeLayout {

        private RelativeLayout top_bar_view ;
        private Button leftBtn ;
        private TextView titleText ;
        private Button rightBtn ;
        public Top_Bar(Context context) {
            super(context);
            initView();
        }

        public Top_Bar(Context context, AttributeSet attrs) {
            super(context, attrs);
            initView();
        }

        private void initView(){
            LayoutInflater.from(getContext()).inflate(R.layout.top_bar , this , true) ;
            top_bar_view = findViewById(R.id.top_bar_1) ;
            leftBtn = findViewById(R.id.leftBtn) ;
            titleText = findViewById(R.id.titleText) ;
            rightBtn = findViewById(R.id.rightBtn);

        }
        public void setTitleText(String text) {
            if (titleText != null && !TextUtils.isEmpty(text)) {
                titleText.setText(text);
            }
        }
        public  void setLeftBtnText(String text){
            leftBtn.setText(text);
        }
        public void  setRightBtnText(String text){
            rightBtn.setText(text);
        }
        public void setLeftBtnClickListener(OnClickListener listener){
            leftBtn.setOnClickListener(listener);
        }
        public void setRightBtnClickListener(OnClickListener listener){
            rightBtn.setOnClickListener(listener);
        }
        public void setBackground(int res){
            top_bar_view.setBackgroundColor(res);
        }
        public void setLeftBtnIsVisible(boolean isVisible){
            leftBtn.setVisibility(VISIBLE);
        }
        public void setLeftBtnNoVisible(boolean isVisible){
            leftBtn.setVisibility(INVISIBLE);
        }
        public void setRightBtnIsVisible(boolean isVisible){
            rightBtn.setVisibility(VISIBLE);
        }
        public void setRightBtnNoVisible(boolean isVisible){
            rightBtn.setVisibility(INVISIBLE);
        }

}
